package com.study.manage.dal;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import com.study.manage.domain.BlogBuy;
import com.study.manage.domain.enumm.LiveDieState;

public interface BlogBuyRepository extends PagingAndSortingRepository<BlogBuy, Long> {


    int countByBlogIdAndState(Long blogId, LiveDieState state);

    @Query("select count(t.id) from BlogBuy t,Orders o where o.id=t.ordersId and t.blogId=:blogId and o.payState=1 and t.state=0")
    Integer countByBlogIdAndPay(@Param("blogId") Long blogId);

}
